package com.scc.entites;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "DISHES")
public class DishEntity implements Comparable<DishEntity>, Serializable
{
   /**
    * 
    */
   private static final long serialVersionUID = 1L;
   
   private Long id;
   private String code;
   private String name;
   private String description;
   private int weight;
   private CategoriesEntity category;
   
   public DishEntity() 
   {
      
   }
   
   public DishEntity(String name, String description, int weight)
   {
      this.name = name;
      this.description = description;
      this.weight = weight;
   }
   
   public DishEntity(String code, String name, String description, int weight)
   {
      this.code = code;
      this.name = name;
      this.description = description;
      this.weight = weight;
   }
   
   public DishEntity(String code, String name, String description, int weight, CategoriesEntity category)
   {
      this.code = code;
      this.name = name;
      this.description = description;
      this.weight = weight;
      this.category = category;
   }
   
   @Id
   @Column(name = "DISH_ID")
   @SequenceGenerator(name = "SEQ_DISHES_ID", sequenceName = "SEQ_DISHES_ID")
   @GeneratedValue(generator = "SEQ_DISHES_ID")
   public Long getId()
   {
      return id;
   }

   public void setId(Long id)
   {
      this.id = id;
   }
   
   @Column(name = "DISH_CODE")
   public String getCode()
   {
      return code;
   }
   
   public void setCode(String code)
   {
      this.code = code;
   }
   
   @Column(name = "DISH_NAME")
   public String getName()
   {
      return name;
   }

   public void setName(String name)
   {
      this.name = name;
   }
   
   @Column(name = "DISH_DESCR")
   public String getDescription()
   {
      return description;
   }

   public void setDescription(String description)
   {
      this.description = description;
   }

   @Column(name = "DISH_WEIGHT")
   public int getWeight()
   {
      return weight;
   }

   public void setWeight(int weight)
   {
      this.weight = weight;
   }
   
   @ManyToOne
   @JoinColumn(name = "CATEGORY_CAT_ID")
   public CategoriesEntity getCategory()
   {
      return category;
   }

   public void setCategory(CategoriesEntity category)
   {
      this.category = category;
   }
   
   @Override
   public int compareTo(DishEntity o)
   {
      return this.code.compareTo(o.getCode());
   }

   @Override
   public String toString()
   {
      return "DishEntity [id=" + id + ", code=" + code + ", name=" + name + ", Description="
            + description + ", weight=" + weight + ", category=" + category
            + "]";
   }
}